<%@ page import = "hibernate.method.GameMethods" %>
<%@ page import = "java.io.*" %>
<%@ page import = "java.sql.Connection" %>
<%@ page import = "java.sql.DriverManager" %>
<%@ page import = "java.sql.PreparedStatement" %>
 
 <%
  int game_id ;
  Connection conn = null;
  
  if ( request.getParameter("game_id") != null )
  {
   
    game_id = Integer.parseInt(request.getParameter("game_id")) ;   
  
    try
    {  
    	String dbURL = "jdbc:mysql://localhost:3306/thesis";
		String dbUser = "root";
		String dbPass = "";

		//Connection conn = null;	
		DriverManager.registerDriver(new com.mysql.jdbc.Driver());
		conn = DriverManager.getConnection(dbURL, dbUser, dbPass);
       conn.setAutoCommit (false);  
  
       // get the image from the database
       byte[] imgData = GameMethods.getGameAvatar( conn, game_id  ) ;   
       // display the image
       response.setContentType("image/gif");
       OutputStream o = response.getOutputStream();
       o.write(imgData);
       o.flush(); 
       o.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw e;
    }
    finally
    {
      conn.close() ;
    }  
  }
%>